import sys, os

sys.path.append(os.getcwd())

from selenium.webdriver.common.by import By

from base.base_action import BaseAction





class BorrowPage(BaseAction):
    # 出借页面

    # 获取出借页面title id = "com.chebao:id/title"
    borrow_title = By.ID, "com.chebao:id/title"

    # 售馨 	com.chebao:id/sellout
    sellout_button = By.ID, "com.chebao:id/sellout"

    # 售馨title  com.chebao:id/title
    sellout_title = By.ID, "com.chebao:id/title"

    # 售馨列表 android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]
    sellout_list = By.XPATH, "android.support.v7.widget.RecyclerView/android.widget.LinearLayout"

    # 返回按钮
    return_button = By.ID, "com.chebao:id/back"

    def __init__(self, driver):
        BaseAction.__init__(self, driver)

    def get_borrow_title(self):
        # 获取出借页面title
        self.switch_app()
        title = self.find_element(self.borrow_title)
        return title.text